home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Games / Abalone 1.4.2 / src / Arnold.a.4mw < prev    next >
Encoding:
Text File  |  1995-09-21  |  1.8 KB  |  69 lines  |  [TEXT/MPS ]

  1. ;;            This is all pretty pathetic.
  2. ;;            After having converted the Think assembly to an MPW version,
  3. ;;            it did not work because of the different parameter offset (see below)
  4. ;;            To have MPW compile a version for MetroWerks, I had to undo this.
  5.  
  6.             SEG        'More'
  7.             DATAREFS    RELATIVE
  8.             
  9.             IMPORT    _neighbour:DATA            ;;    from rules
  10.             IMPORT    _distance:DATA            ;;    from rules
  11.             
  12.             IMPORT    ballVal:DATA            ;;    from own file
  13.             IMPORT    firstTime:DATA            ;;    from own file
  14.             IMPORT    InitArnold:CODE            ;;    from own file
  15.             
  16. Arnold        FUNC    EXPORT
  17.  
  18.             LINK      A6,#$FFFFFFFE
  19.             
  20.             JSR       InitArnold            ;;    Lengthy initialisation in C
  21.             
  22.             movem.l    d3-d6/a2, -(a7)            ;;    save non-temp registers
  23.  
  24. ;;            register initialisation
  25.  
  26.             moveq    #0, d0
  27.             moveq    #0, d2
  28.             moveq    #0, d4
  29.             move    $000c(a6), d6            ;;    !!! IN THINK, OFFSET IS $000C
  30.             movea.l    $0008(a6), a0            ;;    !!! UNDO AGAIN FOR METROWERKS
  31.             lea.l    ballVal, a1
  32.             lea.l    _neighbour, a2
  33.             
  34.             moveq    #0, d5                    ;;    f = 1
  35. L_1            addq    #7, a2                    ;;    a2 = _neighbour[f][0]
  36.             adda.l    #128, a1                ;;    a1 = ballVal[f][0]
  37.             
  38.             move.b    1(a0, d5.w), d4            ;;    d4 = board->field[f]
  39.             beq.s    L_6                        ;;    if (! (owner = board->field[f])) continue;
  40.             
  41.             moveq    #0, d1
  42.             moveq    #5, d3                    ;;    d = topleft
  43.  
  44. ;;            Most Inner Loop
  45.     
  46. L_3            move.b    0(a2, d3.w), d2            ;;*    d2 = Neighbour (f, d)
  47.             cmp.b    0(a0, d2.w), d4            ;;    if (board->field[Neighbour (f, d)] == owner)
  48.             bne.s    L_4
  49.             bset    d3, d1                    ;;    index |= (1 << d)
  50. L_4            dbra    d3, L_3
  51.             lsl        #1, d1                    ;;    shorts (not bytes).
  52.             
  53.             cmp        d6, d4                    ;;    if (owner == player)
  54.             bne.s    L_5
  55.             add        0(a1, d1.w), d0            ;;        boardValue += ballVal[f][index]
  56.             bra.s    L_6                        ;;    else
  57. L_5            sub        0(a1, d1.w), d0            ;;        boardValue -= ballVal[f][index]
  58.     
  59. L_6            addq    #1, d5
  60.             cmp        #$003d, d5
  61.             blt.s    L_1
  62.             
  63.             movem.l    (a7)+, d3-d6/a2            ;;    restore non-temp registers
  64.  
  65.             UNLK      A6
  66.             RTS
  67.  
  68.         ENDF
  69.         END